from django.db import models

# Create your models here.

class Student(models.Model):
    SEX_CHOICES = (('0', '女'), ('1', '男')) #自定义选择变量
    #verbose_name :auth 后台显示的名称
    name = models.CharField(max_length=20,verbose_name="名字")
    # null = True 允许为空 blank=True 允许前端为空
    age = models.IntegerField(null=True,blank=True,verbose_name="年龄")
    sex = models.IntegerField(null=True,blank=True,verbose_name="性别",choices=SEX_CHOICES)
    create_time = models.DateTimeField(auto_now_add=True,verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True,verbose_name="修改时间")
    #数据删除  逻辑删除 状态 ，查询的过滤条件：is_delet=True 被认为数据已删除
    is_delete = models.BooleanField(default=False,verbose_name="逻辑删除")
    classes = models.ForeignKey("Classes",on_delete=models.SET_NULL,null=True)
    class Meta:
        db_table = 'student'

class Classes(models.Model):
    name = models.CharField(max_length=20, verbose_name="名字")
    slogan = models.TextField(null=True,blank=True,verbose_name="班级口号")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="修改时间")
    is_delete = models.BooleanField(default=False, verbose_name="逻辑删除")
    class Meta:
        db_table = 'classes'